from pyeasyaccept.script.Script import Script
import sys
""" 
This class is the Python EasyAccept Runner. It is responsible for execute a
script file and returns the script file tests result.

@author: Gustavo Pereira
"""

class PythonEasyAcceptTestRunner:
    
    def __init__(self, facade, file):
        self.facade = facade
        self.file = file
        self.errorsToReport = sys.maxint
        
    def runScript(self, errorListeners):
        """
        Run a specified test script
        @param errorListeners: the error listeners.
        """   
        script = Script(self.facade, self.file)
        for listener in errorListeners:
            script.addErrorListener(listener)
        script.setNumberErrorsToReport(self.errorsToReport)
        script.runScript()
        return script.getScriptResultManager()
 
    def setNumberErrorsToReport(self,errorsToReport):
        self.errorsToReport = errorsToReport